home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-ngcoty.ads < prev    next >
Text File  |  1996-01-30  |  6KB  |  138 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --   A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S    --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.5 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. generic
  19.    type Real is digits <>;
  20.  
  21. package Ada.Numerics.Generic_Complex_Types is
  22.  
  23. pragma Pure (Generic_Complex_Types);
  24.  
  25.    type Complex is record
  26.       Re, Im : Real'Base;
  27.    end record;
  28.  
  29.    type Imaginary is private;
  30.  
  31.    i : constant Imaginary;
  32.    j : constant Imaginary;
  33.  
  34.    function Re (X : Complex)   return Real'Base;
  35.    function Im (X : Complex)   return Real'Base;
  36.    function Im (X : Imaginary) return Real'Base;
  37.  
  38.    procedure Set_Re (X  : in out Complex;   Re : in Real'Base);
  39.    procedure Set_Im (X  : in out Complex;   Im : in Real'Base);
  40.    procedure Set_Im (X  :    out Imaginary; Im : in Real'Base);
  41.  
  42.    function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
  43.    function Compose_From_Cartesian (Re     : Real'Base) return Complex;
  44.    function Compose_From_Cartesian (Im     : Imaginary) return Complex;
  45.  
  46.    function Modulus (X     : Complex) return Real'Base;
  47.    function "abs"   (Right : Complex) return Real'Base renames Modulus;
  48.  
  49.    function Argument (X : Complex)                    return Real'Base;
  50.    function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
  51.  
  52.    function Compose_From_Polar (
  53.      Modulus, Argument : Real'Base)
  54.      return Complex;
  55.  
  56.    function Compose_From_Polar (
  57.      Modulus, Argument, Cycle : Real'Base)
  58.      return Complex;
  59.  
  60.    function "+"       (Right : Complex) return Complex;
  61.    function "-"       (Right : Complex) return Complex;
  62.    function Conjugate (X     : Complex) return Complex;
  63.  
  64.    function "+"       (Left, Right : Complex) return Complex;
  65.    function "-"       (Left, Right : Complex) return Complex;
  66.    function "*"       (Left, Right : Complex) return Complex;
  67.    function "/"       (Left, Right : Complex) return Complex;
  68.  
  69.    function "**"      (Left : Complex; Right : Integer) return Complex;
  70.  
  71.    function "+"       (Right : Imaginary) return Imaginary;
  72.    function "-"       (Right : Imaginary) return Imaginary;
  73.    function Conjugate (X     : Imaginary) return Imaginary renames "-";
  74.    function "abs"     (Right : Imaginary) return Real'Base;
  75.  
  76.    function "+"       (Left, Right : Imaginary) return Imaginary;
  77.    function "-"       (Left, Right : Imaginary) return Imaginary;
  78.    function "*"       (Left, Right : Imaginary) return Real'Base;
  79.    function "/"       (Left, Right : Imaginary) return Real'Base;
  80.  
  81.    function "**"      (Left : Imaginary; Right : Integer) return Complex;
  82.  
  83.    function "<"       (Left, Right : Imaginary) return Boolean;
  84.    function "<="      (Left, Right : Imaginary) return Boolean;
  85.    function ">"       (Left, Right : Imaginary) return Boolean;
  86.    function ">="      (Left, Right : Imaginary) return Boolean;
  87.  
  88.    function "+"       (Left : Complex;   Right : Real'Base) return Complex;
  89.    function "+"       (Left : Real'Base; Right : Complex)   return Complex;
  90.    function "-"       (Left : Complex;   Right : Real'Base) return Complex;
  91.    function "-"       (Left : Real'Base; Right : Complex)   return Complex;
  92.    function "*"       (Left : Complex;   Right : Real'Base) return Complex;
  93.    function "*"       (Left : Real'Base; Right : Complex)   return Complex;
  94.    function "/"       (Left : Complex;   Right : Real'Base) return Complex;
  95.    function "/"       (Left : Real'Base; Right : Complex)   return Complex;
  96.  
  97.    function "+"       (Left : Complex;   Right : Imaginary) return Complex;
  98.    function "+"       (Left : Imaginary; Right : Complex)   return Complex;
  99.    function "-"       (Left : Complex;   Right : Imaginary) return Complex;
  100.    function "-"       (Left : Imaginary; Right : Complex)   return Complex;
  101.    function "*"       (Left : Complex;   Right : Imaginary) return Complex;
  102.    function "*"       (Left : Imaginary; Right : Complex)   return Complex;
  103.    function "/"       (Left : Complex;   Right : Imaginary) return Complex;
  104.    function "/"       (Left : Imaginary; Right : Complex)   return Complex;
  105.  
  106.    function "+"       (Left : Imaginary; Right : Real'Base) return Complex;
  107.    function "+"       (Left : Real'Base; Right : Imaginary) return Complex;
  108.    function "-"       (Left : Imaginary; Right : Real'Base) return Complex;
  109.    function "-"       (Left : Real'Base; Right : Imaginary) return Complex;
  110.  
  111.    function "*"       (Left : Imaginary; Right : Real'Base) return Imaginary;
  112.    function "*"       (Left : Real'Base; Right : Imaginary) return Imaginary;
  113.    function "/"       (Left : Imaginary; Right : Real'Base) return Imaginary;
  114.    function "/"       (Left : Real'Base; Right : Imaginary) return Imaginary;
  115.  
  116. private
  117.    type Imaginary is new Real'Base;
  118.  
  119.    i : constant Imaginary := 1.0;
  120.    j : constant Imaginary := 1.0;
  121.  
  122.    pragma Inline ("+");
  123.    pragma Inline ("-");
  124.    pragma Inline ("*");
  125.    pragma Inline ("<");
  126.    pragma Inline ("<=");
  127.    pragma Inline (">");
  128.    pragma Inline (">=");
  129.    pragma Inline ("abs");
  130.    pragma Inline (Compose_From_Cartesian);
  131.    pragma Inline (Conjugate);
  132.    pragma Inline (Im);
  133.    pragma Inline (Re);
  134.    pragma Inline (Set_Im);
  135.    pragma Inline (Set_Re);
  136.  
  137. end Ada.Numerics.Generic_Complex_Types;
  138.